<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="6"><div class="grid-content bg-purple" />设备名称:</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />{{ detail.name }}</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />站点:</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />{{ detail.groupName }}</el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6"><div class="grid-content bg-purple" />产品名称:</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />{{ detail.productName }}</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />设备描述:</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />{{ detail.description }}</el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6"><div class="grid-content bg-purple" />设备key</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />{{ detail.key }}</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />设备secret</el-col>
      <el-col :span="6"><div class="grid-content bg-purple" />{{ detail.secret }}</el-col>
    </el-row>
  </div>

</template>

<script>
import { deviceDetail, updateDevice } from '@/api/device'
export default {
  data() {
    return {
      deviceId: undefined,
      detail: {}
    }
  },
  created() {
    this.deviceId = this.$route.params && this.$route.params.id
    this.getdeviceDetail()
  },
  methods: {
    getdeviceDetail() {
      deviceDetail(this.deviceId).then(res => {
        this.detail = res.data
      })
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          addProduct(this.dynamicValidateForm).then(response => {
            this.$router.push({ path: '/device/product' })
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    },
    removeDomain(item) {
      var index = this.dynamicValidateForm.attributes.indexOf(item)
      if (index !== -1) {
        this.dynamicValidateForm.attributes.splice(index, 1)
      }
    },
    addAttribute() {
      this.dynamicValidateForm.attributes.push({
        type: '',
        name: '',
        key: Date.now()
      })
    }
  }
}
</script>

<style>

</style>
